package com.z.demo01

import org.apache.flink.streaming.api.scala._

/**
 * @Author wenz.ma
 * @Date 2021/10/29 10:43
 * @Desc
 */
object Demo01 {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    val inputStream: DataStream[String] = env.socketTextStream("server120", 9999)
    inputStream
      .filter(_.startsWith("")) //过滤
      /*.flatMap(_.split(",")) //拆分
      .map({ v => {
        (v, 1)
      }
      }) //组合
      .keyBy(x => {
        x._1
      }) //分组
      .sum(1) //求和*/
      .print() //打印
    env.execute()
  }
}
